 <?php

// NOTE: This web-service is available only on the commercial edition of LD
// to thest it you should enable its client on sharedResources.php

require ("sharedResources.php");

$sid = '';
try {
    // We need a SID (session ID) in order to operate
    $sid = login ( 'admin', 'admin' );
    //echo 'sid: ' . $sid . PHP_EOL;
    

        $templateId = 1; // template 'email'
        
        $criteria[0]['field'] = "subject";
        $criteria[0]['operator'] = "contains";
        $criteria[0]['stringValue'] = "ZDNet Tech Today";              
        $criteria[0]['type'] = 0; // 0=string att, 1=integer etc.., 2=double,3=date,4=user,5=boolean
        $criteria[0]['extendedAttribute'] = 1; // 0=standard attribute, 1=extended attribute
        //$criteria[0]['composition'] = "and";               

        $searchParams = array ('sid' => $sid, 'templateId' => $templateId, 'criteria' => $criteria, 'maxResults' => 100);

        $results = $searchClientEnterprise->findByParameters($searchParams);
        print "<br><br>";
print_r($results);

print "<br><br><pre>\n";
print "Request :\n".htmlspecialchars($searchClientEnterprise->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($searchClientEnterprise->__getLastResponse())."\n";
print "</pre>";
        
        
/*        
        if (! empty ( $result->searchResult->hits )) {
            $documents = $result->searchResult->hits;
if (sizeof ( $documents ) == 1) {
      echo 'Search returned just 1 document'. PHP_EOL;      
       print_r($documents->title . "<br>");
      return;
    }        		
		
		foreach ( $result->searchResult->hits as $doc ) {	
		   print_r($doc->title . "<br>");
		}            
        } else {
		echo 'Your search did not match any documents' .PHP_EOL;
    print_r($results);
	}   
  */  
        
        //print_r("<strong>" . count($results->hit). "<br></strong>");
        //print_r($results);
        //echo $results;
    
//unset ( $folderClient );
} catch ( SoapFault $e ) {
    print_r("ERROR:"."<br>");
    print_r ( $e );
}

//$sid = '';
// Always we need to logout in order to release connection slot
logout ( $sid );

?>  